package com.dllo.lanou.cookapp.adapter;

/**
 * Created by xijinhua on 2016/3/21.
 */
import java.util.List;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.TextView;

import com.dllo.lanou.cookapp.R;
import com.dllo.lanou.cookapp.entity.BookPage;
import com.dllo.lanou.cookapp.view.PageAdapter;

public class ScanViewAdapter extends PageAdapter
{
    Context context;
    List<BookPage>  bookPages;
    AssetManager am;

    WebSettings settings;
    public ScanViewAdapter(Context context,  List<BookPage>  bookPages)
    {
        this.context = context;
        this.bookPages = bookPages;

        Log.i("书籍的详情信息web",bookPages+"");
        am = context.getAssets();
    }

    public void addContent(View view, int position)
    {
       TextView content = (TextView) view.findViewById(R.id.title);
        TextView doWebView = (TextView) view.findViewById(R.id.book_des_content);
        BookPage bookPage =bookPages.get(position);
        if (bookPages !=null)

        {

            content.setText(bookPage.getTitle());
//            String htmlString = bookPage.getMessage();
//            final String mimrTypeString = "text/html";
//            final String encoding = "utf-8";
//
//            settings = doWebView.getSettings();
//            settings.setSupportZoom(true);
//            doWebView.loadDataWithBaseURL("fake://not/needed", htmlString, mimrTypeString, encoding, "");
//            settings.setTextZoom(150);
//            settings.setTextSize(WebSettings.TextSize.LARGEST);
//
//            doWebView.setInitialScale(100);

            String message = bookPage.getMessage();

            String message2 = message.replace("<div> \\n <div></div> \\n <p></p> \\n <p>", "\\n ");
            doWebView.setText(message2);

        }
    }

    public int getCount()
    {
        return bookPages.size()>0&& bookPages != null?bookPages.size():0;
    }

    public View getView()
    {
        View view = LayoutInflater.from(context).inflate(R.layout.item_readpage,null);
        return view;
    }
}
